<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>锋陪-陪诊师</title>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>

</head>
<body>
<div>
    <div>
        <h3>认证陪诊师</h3>
        <div>
            <div><label>手机号：</label><input place="请输入手机号"/></div>
            <div><label>认证城市：</label>
            <select>
                <option value="">请选择要认证的城市</option>
                <option value="北京市">北京市</option>
                <option value="上海市">上海市</option>
                <option value="郑州市">郑州市</option>
                <option value="武汉市">武汉市</option>
                <option value="深圳市">深圳市</option>
                <option value="广州市">广州市</option>
            </select>
            </div>
            <div>
                <label>身份证正面：</label>
                <input type="file" id="cardf">
                <button onclick="uploadFile('cardf')">上传</button>
            </div>
            <div>
                <label>身份证反面：</label>
                <input type="file" id="cardb">
                <button onclick="uploadFile('cardb')">上传</button>
            </div>
            <div>
                <label>健康证正面：</label>
                <input type="file" id="health">
                <button onclick="uploadFile('health')">上传</button>
            </div>
            <div><button onclick="">申请陪诊师认证</button></div>
        </div>

    </div>

    <div>
        <label>陪诊师ID：</label><input placeholder="请输入你的陪诊师ID" id="pid">
        <button onclick="createPay()">发起支付</button>
    </div>
</div>

<script>
    var data={
        "phone": "21",
        "city": "2",
        "excel": "2",
        "cardFront": "",
        "cardBack": "",
        "healthCard": ""
    }
    function uploadFile(id) {
        const input = document.getElementById(id);
        const file = input.files[0]; // 获取文件
        const formData = new FormData(); // 创建FormData对象
        formData.append('file', file); // 将文件添加到FormData

        const xhr = new XMLHttpRequest();
        xhr.open('POST', '/upload', true); // 设置请求方法、URL和异步
        xhr.onload = function() {
            if (this.status == 200) {
                console.log('上传成功');
            } else {
                console.error('上传失败');
            }
        };
        xhr.send(formData); // 发送FormData
    }
    function  createPay(){
        id=document.getElementById("pid").value;
        axios.get('/api/physician/addpay?id='+id).then(res=>{
            console.log(res)

            document.write(res.data.data)

        }).catch(err=>{
            console.log(err)
        })

    }
</script>
</body>
</html>